<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<div class="form-horizontal m-t">
							<div class="col-sm-12">
								<div class="form-group">
									<label class="col-sm-3 control-label">资料名称：</label>
									<div class="col-sm-8">
										<input id="studyResourceName" name="studyResourceName" class="form-control" type="text">
									</div>
								</div>
							</div>
							<div class="col-sm-12">
								<div class="form-group">
									<label class="col-sm-3 control-label">适应年级：</label>
									<div class="col-sm-8">
										<select data-placeholder="--选择班级--" name="unit" id="unit"
												class="form-control chosen-select" tabindex="2">
											<option value="">-- 选择班级 --</option>
											<option value="1">一年级</option>
											<option text="二年级" value="2">二年级</option>
											<option text="三年级" value="3">三年级</option>
											<option text="四年级" value="4">四年级</option>
											<option text="五年级" value="5">五年级</option>
											<option text="六年级" value="6">六年级</option>
										</select>
									</div>
								</div>
							</div>

							<div class="col-sm-12">
								<div class="form-group">
									<label class="col-sm-3 control-label">上传文件：</label>
									<div class="col-sm-8">
										<input id="uploadFile" name="uploadFile" class="form-control"
											   type="file">
									</div>
								</div>
							</div>




							<div class="form-group">
								<div class="col-sm-5 col-sm-offset-5">
									<button type="submit" onclick="save1()" class="btn btn-primary">提交</button>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

	</div>
	<div th:include="include::footer"></div>
	<script type="text/javascript">
		function save1(){
			var studyResrouceName = $('#studyResourceName').val();
			var unit = $('#unit').val();
			if(studyResrouceName == ""){
				parent.layer.alert("资料名称不能为空");
				return false;
			}
			if(unit == ""){
				parent.layer.alert("适应年级不能为空");
				return false;
			}
			$("#uploadFile").fileinput("upload");
		}
		$("#uploadFile").fileinput({
			dropZoneTitle : "可拖拽文件至此处或点击选择按钮！(文件大小不超过100M)",
			uploadUrl : "/study/uploadResource",
			language : "zh",
			autoReplace : true,
			showCaption : false,
			showUpload : false,
			overwriteInitial : true,
			showUploadedThumbs : true,
			//showPreview:false,                   //显示上传图片的大小信息
			maxFileCount : 1,
			minFileCount:1,
			maxFileSize : 153600,//文件最大153600kb=150M
			initialPreviewShowDelete : false,
			showRemove : false,//是否显示删除按钮
			showClose : false,
			layoutTemplates : {
				actionUpload:'',
			},
			allowedFileExtensions : [ "mp4","avi","dat","3gp","mov","rmvb"],
			previewSettings : {
				image : {
					width : "100%",
					height : "100%"
				},
			},
			uploadExtraData:function(){
				var date = {
					studyResrouceName: $('#studyResourceName').val(),
					unit: $('#unit').val()
				}
				return date;
			}
		}).on('fileuploaded',function (event, data, previewId, index){
			if(data.response.code == 0){
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);
			}
		});
	</script>
	<script type="text/javascript" src="/js/appjs/study/add.js">
	</script>
</body>
</html>
